Skip to content

Improve narrowing with numeric types#20727

Open
hauntsaninja wants to merge 1 commit intopython:masterfrom
hauntsaninja:narrow80
Open

Improve narrowing with numeric types#20727
hauntsaninja wants to merge 1 commit intopython:masterfrom
hauntsaninja:narrow80

Conversation

@hauntsaninja
Copy link
Collaborator

I added tests for this change in #20709 so it's easier to see the diff. Like a few others, this was factored out of #20660 to make that one easier to land.
The change in bytes narrowing is also desirable (but unfortunately only applies with --no-strict-bytes). We can figure out something else for that case, as discussed in #20704

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Feb 3, 2026

The primer diff + the tests will be fixed by #20728

@github-actions

This comment has been minimized.

hauntsaninja added a commit that referenced this pull request Feb 6, 2026
Previously we considered the else branch unreachable in the
`testNarrowingAnyUnion` test case. It's also nice that the new code is
more obviously correct

Fixes #20330

This will help with landing #20727 as well
I added tests for this change in python#20709 so it's easier to see the diff.
Like a few others, this was factored out of python#20660 to make that one
easier to land.
The change in bytes narrowing is also desirable (but unfortunately
only applies with --no-strict-bytes). We can figure out something else
for that case
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja marked this pull request as ready for review February 6, 2026 21:59
@hauntsaninja
Copy link
Collaborator Author

Several of the problems here are pre-existing, so not a release blocker, but would be very good to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant